﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace SpringBeansEditor.Commands
{
    public class AddObjectCommand : IXmlCommand
    {
        public delegate void ExecutedDelegate(IXmlCommand cmd);
        public ExecutedDelegate OnExecute { get; set; }

        public bool IsAllowedInNode(XmlNode curr_xml_node)
        {
            return (curr_xml_node.Name.ToLowerInvariant() == "objects");
        }

        public string GetLabel()
        {
            return "Add Object";
        }

        public void Execute(XmlDocument xml_data, XmlNode curr_xml_node)
        {
            string node_name = curr_xml_node.Name.ToLowerInvariant();
            XmlElement new_node = xml_data.CreateElement("object","http://www.springframework.net");
            new_node.SetAttribute("id", "");
            new_node.SetAttribute("type", "");
            //new_node.n
            curr_xml_node.AppendChild(new_node);
            OnExecute(this);
        }
    }
}
